<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>ActiveRecord::Core</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../css/github.css" type="text/css" media="screen" />
<script src="../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Module</span> 
            ActiveRecord::Core 
            
        </h1>
        <ul class="files">
            
            <li><a href="../../files/activerecord/lib/active_record/core_rb.html">activerecord/lib/active_record/core.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  


  


  
  


  
    <!-- Namespace -->
    <div class="sectiontitle">Namespace</div>
    <ul>
      
        <li>
          <span class="type">MODULE</span>
          <a href="Core/ClassMethods.html">ActiveRecord::Core::ClassMethods</a>
        </li>
      
    </ul>
  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>#</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Core.html#method-i-3C-3D-3E">&lt;=&gt;</a>,
              </li>
            
              
              <li>
                <a href="Core.html#method-i-3D-3D">==</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>C</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Core.html#method-i-clone">clone</a>,
              </li>
            
              
              <li>
                <a href="Core.html#method-i-connection">connection</a>,
              </li>
            
              
              <li>
                <a href="Core.html#method-i-connection_handler">connection_handler</a>,
              </li>
            
              
              <li>
                <a href="Core.html#method-c-connection_handler">connection_handler</a>,
              </li>
            
              
              <li>
                <a href="Core.html#method-c-connection_handler-3D">connection_handler=</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>D</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Core.html#method-i-dup">dup</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>E</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Core.html#method-i-encode_with">encode_with</a>,
              </li>
            
              
              <li>
                <a href="Core.html#method-i-eql-3F">eql?</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>F</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Core.html#method-i-freeze">freeze</a>,
              </li>
            
              
              <li>
                <a href="Core.html#method-i-frozen-3F">frozen?</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>H</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Core.html#method-i-hash">hash</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>I</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Core.html#method-i-init_with">init_with</a>,
              </li>
            
              
              <li>
                <a href="Core.html#method-i-inspect">inspect</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>N</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Core.html#method-c-new">new</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>R</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Core.html#method-i-readonly-21">readonly!</a>,
              </li>
            
              
              <li>
                <a href="Core.html#method-i-readonly-3F">readonly?</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>S</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Core.html#method-i-slice">slice</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    


    


    <!-- Methods -->
    
      <div class="sectiontitle">Class Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-c-connection_handler">
            
              <b>connection_handler</b>()
            
            <a href="Core.html#method-c-connection_handler" name="method-c-connection_handler" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-connection_handler_source')" id="l_method-c-connection_handler_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L82" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-connection_handler_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 82</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">self</span>.<span class="ruby-identifier">connection_handler</span>
  <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">RuntimeRegistry</span>.<span class="ruby-identifier">connection_handler</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">default_connection_handler</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-connection_handler-3D">
            
              <b>connection_handler=</b>(handler)
            
            <a href="Core.html#method-c-connection_handler-3D" name="method-c-connection_handler-3D" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-connection_handler-3D_source')" id="l_method-c-connection_handler-3D_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L86" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-connection_handler-3D_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 86</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">self</span>.<span class="ruby-identifier">connection_handler=</span>(<span class="ruby-identifier">handler</span>)
  <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">RuntimeRegistry</span>.<span class="ruby-identifier">connection_handler</span> = <span class="ruby-identifier">handler</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-new">
            
              <b>new</b>(attributes = nil)
            
            <a href="Core.html#method-c-new" name="method-c-new" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>New objects can be instantiated as either empty (pass no construction
parameter) or pre-set with attributes but not yet saved (pass a hash with
key names matching the associated table column names). In both instances,
valid attribute keys are determined by the column names of the associated
table – hence you can’t have attributes that aren’t part of the table
columns.</p>

<h4 id="method-c-new-label-Example%3A">Example:</h4>

<pre># Instantiates a single new object
User.new(first_name: 'Jamie')</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-new_source')" id="l_method-c-new_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L180" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-new_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 180</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">initialize</span>(<span class="ruby-identifier">attributes</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">defaults</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">column_defaults</span>.<span class="ruby-identifier">dup</span>
  <span class="ruby-identifier">defaults</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">defaults</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>.<span class="ruby-identifier">dup</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">duplicable?</span> }

  <span class="ruby-ivar">@attributes</span>   = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">initialize_attributes</span>(<span class="ruby-identifier">defaults</span>)
  <span class="ruby-ivar">@columns_hash</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">column_types</span>.<span class="ruby-identifier">dup</span>

  <span class="ruby-identifier">init_internals</span>
  <span class="ruby-identifier">init_changed_attributes</span>
  <span class="ruby-identifier">ensure_proper_type</span>
  <span class="ruby-identifier">populate_with_current_scope_attributes</span>

  <span class="ruby-identifier">assign_attributes</span>(<span class="ruby-identifier">attributes</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">attributes</span>

  <span class="ruby-keyword">yield</span> <span class="ruby-keyword">self</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
  <span class="ruby-identifier">run_callbacks</span> <span class="ruby-value">:initialize</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">_initialize_callbacks</span>.<span class="ruby-identifier">empty?</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                  
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-3C-3D-3E">
            
              <b>&lt;=&gt;</b>(other_object)
            
            <a href="Core.html#method-i-3C-3D-3E" name="method-i-3C-3D-3E" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Allows sort on objects</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-3C-3D-3E_source')" id="l_method-i-3C-3D-3E_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L324" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-3C-3D-3E_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 324</span>
<span class="ruby-keyword">def</span> <span class="ruby-operator">&lt;=&gt;</span>(<span class="ruby-keyword ruby-title">other_object</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">other_object</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>)
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">to_key</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">other_object</span>.<span class="ruby-identifier">to_key</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-3D-3D">
            
              <b>==</b>(comparison_object)
            
            <a href="Core.html#method-i-3D-3D" name="method-i-3D-3D" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns true if <code>comparison_object</code> is the same exact object, or
<code>comparison_object</code> is of the same type and <code>self</code>
has an ID and it is equal to <code>comparison_object.id</code>.</p>

<p>Note that new records are different from any other record by definition,
unless the other record is the receiver itself. Besides, if you fetch
existing records with <code>select</code> and leave the ID out, you’re on
your own, this predicate will return false.</p>

<p>Note also that destroying a record preserves its ID in the model instance,
so deleted models are still comparable.</p>
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Core.html#method-i-eql-3F">eql?</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-3D-3D_source')" id="l_method-i-3D-3D_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L296" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-3D-3D_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 296</span>
<span class="ruby-keyword">def</span> <span class="ruby-operator">==</span>(<span class="ruby-keyword ruby-title">comparison_object</span>)
  <span class="ruby-keyword">super</span> <span class="ruby-operator">||</span>
    <span class="ruby-identifier">comparison_object</span>.<span class="ruby-identifier">instance_of?</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>) <span class="ruby-operator">&amp;&amp;</span>
    <span class="ruby-identifier">id</span>.<span class="ruby-identifier">present?</span> <span class="ruby-operator">&amp;&amp;</span>
    <span class="ruby-identifier">comparison_object</span>.<span class="ruby-identifier">id</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">id</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-clone">
            
              <b>clone</b>
            
            <a href="Core.html#method-i-clone" name="method-i-clone" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Identical to Ruby’s clone method.  This is a “shallow” copy.  Be warned
that your attributes are not copied. That means that modifying attributes
of the clone will modify the original, since they will both point to the
same attributes hash. If you need a copy of your attributes hash, please
use the <a href="Core.html#method-i-dup">dup</a> method.</p>

<pre class="ruby"><span class="ruby-identifier">user</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">first</span>
<span class="ruby-identifier">new_user</span> = <span class="ruby-identifier">user</span>.<span class="ruby-identifier">clone</span>
<span class="ruby-identifier">user</span>.<span class="ruby-identifier">name</span>               <span class="ruby-comment"># =&gt; &quot;Bob&quot;</span>
<span class="ruby-identifier">new_user</span>.<span class="ruby-identifier">name</span> = <span class="ruby-string">&quot;Joe&quot;</span>
<span class="ruby-identifier">user</span>.<span class="ruby-identifier">name</span>               <span class="ruby-comment"># =&gt; &quot;Joe&quot;</span>

<span class="ruby-identifier">user</span>.<span class="ruby-identifier">object_id</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">new_user</span>.<span class="ruby-identifier">object_id</span>            <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-identifier">user</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">object_id</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">new_user</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">object_id</span>  <span class="ruby-comment"># =&gt; true</span>

<span class="ruby-identifier">user</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">object_id</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">user</span>.<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">object_id</span>  <span class="ruby-comment"># =&gt; false</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-clone_source')" id="l_method-i-clone_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L239" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-clone_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 239</span>
    </pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-connection">
            
              <b>connection</b>()
            
            <a href="Core.html#method-i-connection" name="method-i-connection" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns the connection currently associated with the class. This can also
be used to “borrow” the connection to do database work that isn’t easily
done without going straight to SQL.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-connection_source')" id="l_method-i-connection_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L344" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-connection_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 344</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">connection</span>
  <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">Deprecation</span>.<span class="ruby-identifier">warn</span>(<span class="ruby-node">&quot;#connection is deprecated in favour of accessing it via the class&quot;</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">connection</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-connection_handler">
            
              <b>connection_handler</b>()
            
            <a href="Core.html#method-i-connection_handler" name="method-i-connection_handler" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-connection_handler_source')" id="l_method-i-connection_handler_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L349" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-connection_handler_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 349</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">connection_handler</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">connection_handler</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-dup">
            
              <b>dup</b>
            
            <a href="Core.html#method-i-dup" name="method-i-dup" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Duped objects have no id assigned and are treated as new records. Note that
this is a “shallow” copy as it copies the object’s attributes only, not its
associations. The extent of a “deep” copy is application specific and is
therefore left to the application to implement according to its need. The
dup method does not preserve the timestamps (created|updated)_(at|on).</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-dup_source')" id="l_method-i-dup_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L248" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-dup_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 248</span>
    </pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-encode_with">
            
              <b>encode_with</b>(coder)
            
            <a href="Core.html#method-i-encode_with" name="method-i-encode_with" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Populate <code>coder</code> with attributes about this record that should
be serialized. The structure of <code>coder</code> defined in this method
is guaranteed to match the structure of <code>coder</code> passed to the
<code>init_with</code> method.</p>

<p>Example:</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Post</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>
<span class="ruby-keyword">end</span>
<span class="ruby-identifier">coder</span> = {}
<span class="ruby-constant">Post</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">encode_with</span>(<span class="ruby-identifier">coder</span>)
<span class="ruby-identifier">coder</span> <span class="ruby-comment"># =&gt; {&quot;attributes&quot; =&gt; {&quot;id&quot; =&gt; nil, ... }}</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-encode_with_source')" id="l_method-i-encode_with_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L283" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-encode_with_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 283</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">encode_with</span>(<span class="ruby-identifier">coder</span>)
  <span class="ruby-identifier">coder</span>[<span class="ruby-string">'attributes'</span>] = <span class="ruby-identifier">attributes</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-eql-3F">
            
              <b>eql?</b>(comparison_object)
            
            <a href="Core.html#method-i-eql-3F" name="method-i-eql-3F" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-freeze">
            
              <b>freeze</b>()
            
            <a href="Core.html#method-i-freeze" name="method-i-freeze" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Clone and freeze the attributes hash such that associations are still
accessible, even on destroyed records, but cloned models will not be
frozen.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-freeze_source')" id="l_method-i-freeze_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L313" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-freeze_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 313</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">freeze</span>
  <span class="ruby-ivar">@attributes</span> = <span class="ruby-ivar">@attributes</span>.<span class="ruby-identifier">clone</span>.<span class="ruby-identifier">freeze</span>
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-frozen-3F">
            
              <b>frozen?</b>()
            
            <a href="Core.html#method-i-frozen-3F" name="method-i-frozen-3F" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns <code>true</code> if the attributes hash has been frozen.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-frozen-3F_source')" id="l_method-i-frozen-3F_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L319" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-frozen-3F_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 319</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">frozen?</span>
  <span class="ruby-ivar">@attributes</span>.<span class="ruby-identifier">frozen?</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-hash">
            
              <b>hash</b>()
            
            <a href="Core.html#method-i-hash" name="method-i-hash" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Delegates to id in order to allow two records of the same type and id to
work with something like:</p>

<pre class="ruby">[ <span class="ruby-constant">Person</span>.<span class="ruby-identifier">find</span>(<span class="ruby-value">1</span>), <span class="ruby-constant">Person</span>.<span class="ruby-identifier">find</span>(<span class="ruby-value">2</span>), <span class="ruby-constant">Person</span>.<span class="ruby-identifier">find</span>(<span class="ruby-value">3</span>) ] &amp; [ <span class="ruby-constant">Person</span>.<span class="ruby-identifier">find</span>(<span class="ruby-value">1</span>), <span class="ruby-constant">Person</span>.<span class="ruby-identifier">find</span>(<span class="ruby-value">4</span>) ] <span class="ruby-comment"># =&gt; [ Person.find(1) ]</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-hash_source')" id="l_method-i-hash_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L306" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-hash_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 306</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">hash</span>
  <span class="ruby-identifier">id</span>.<span class="ruby-identifier">hash</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-init_with">
            
              <b>init_with</b>(coder)
            
            <a href="Core.html#method-i-init_with" name="method-i-init_with" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Initialize an empty model object from <code>coder</code>.
<code>coder</code> must contain the attributes necessary for initializing
an empty model object. For example:</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">Post</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>
<span class="ruby-keyword">end</span>

<span class="ruby-identifier">post</span> = <span class="ruby-constant">Post</span>.<span class="ruby-identifier">allocate</span>
<span class="ruby-identifier">post</span>.<span class="ruby-identifier">init_with</span>(<span class="ruby-string">'attributes'</span> =<span class="ruby-operator">&gt;</span> { <span class="ruby-string">'title'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'hello world'</span> })
<span class="ruby-identifier">post</span>.<span class="ruby-identifier">title</span> <span class="ruby-comment"># =&gt; 'hello world'</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-init_with_source')" id="l_method-i-init_with_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L208" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-init_with_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 208</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">init_with</span>(<span class="ruby-identifier">coder</span>)
  <span class="ruby-ivar">@attributes</span>   = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">initialize_attributes</span>(<span class="ruby-identifier">coder</span>[<span class="ruby-string">'attributes'</span>])
  <span class="ruby-ivar">@columns_hash</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">column_types</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">coder</span>[<span class="ruby-string">'column_types'</span>] <span class="ruby-operator">||</span> {})

  <span class="ruby-identifier">init_internals</span>

  <span class="ruby-ivar">@new_record</span> = <span class="ruby-keyword">false</span>

  <span class="ruby-identifier">run_callbacks</span> <span class="ruby-value">:find</span>
  <span class="ruby-identifier">run_callbacks</span> <span class="ruby-value">:initialize</span>

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-inspect">
            
              <b>inspect</b>()
            
            <a href="Core.html#method-i-inspect" name="method-i-inspect" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns the contents of the record as a nicely formatted string.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-inspect_source')" id="l_method-i-inspect_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L354" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-inspect_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 354</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">inspect</span>
  <span class="ruby-comment"># We check defined?(@attributes) not to issue warnings if the object is</span>
  <span class="ruby-comment"># allocated but not initialized.</span>
  <span class="ruby-identifier">inspection</span> = <span class="ruby-keyword">if</span> <span class="ruby-keyword">defined?</span>(<span class="ruby-ivar">@attributes</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@attributes</span>
                 <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">column_names</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span>
                   <span class="ruby-keyword">if</span> <span class="ruby-identifier">has_attribute?</span>(<span class="ruby-identifier">name</span>)
                     <span class="ruby-node">&quot;#{name}: #{attribute_for_inspect(name)}&quot;</span>
                   <span class="ruby-keyword">end</span>
                 }.<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;, &quot;</span>)
               <span class="ruby-keyword">else</span>
                 <span class="ruby-string">&quot;not initialized&quot;</span>
               <span class="ruby-keyword">end</span>
  <span class="ruby-node">&quot;#&lt;#{self.class} #{inspection}&gt;&quot;</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-readonly-21">
            
              <b>readonly!</b>()
            
            <a href="Core.html#method-i-readonly-21" name="method-i-readonly-21" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Marks this record as read only.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-readonly-21_source')" id="l_method-i-readonly-21_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L337" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-readonly-21_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 337</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">readonly!</span>
  <span class="ruby-ivar">@readonly</span> = <span class="ruby-keyword">true</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-readonly-3F">
            
              <b>readonly?</b>()
            
            <a href="Core.html#method-i-readonly-3F" name="method-i-readonly-3F" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns <code>true</code> if the record is read only. Records loaded
through joins with piggy-back attributes will be marked as read only since
they cannot be saved.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-readonly-3F_source')" id="l_method-i-readonly-3F_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L332" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-readonly-3F_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 332</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">readonly?</span>
  <span class="ruby-ivar">@readonly</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-slice">
            
              <b>slice</b>(*methods)
            
            <a href="Core.html#method-i-slice" name="method-i-slice" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a hash of the given methods with their names as keys and returned
values as values.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-slice_source')" id="l_method-i-slice_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/607f136d52e984323cbe2938c04c660ca55a5039/activerecord/lib/active_record/core.rb#L370" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-slice_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activerecord/lib/active_record/core.rb, line 370</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">slice</span>(*<span class="ruby-identifier">methods</span>)
  <span class="ruby-constant">Hash</span>[<span class="ruby-identifier">methods</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">method</span><span class="ruby-operator">|</span> [<span class="ruby-identifier">method</span>, <span class="ruby-identifier">public_send</span>(<span class="ruby-identifier">method</span>)] }].<span class="ruby-identifier">with_indifferent_access</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>    